// 请求响应参数（不包含data）
export interface Result {
  success: boolean;
  code: number;
  msg: string;
}

// 请求响应参数（包含data）
export interface ResultData<T = any> extends Result {
  data: T;
}

// 分页响应参数
export interface ResPage<T> {
  list: T[];
  pageNum: number;
  pageSize: number;
  total: number;
  summary: any;
}

// 分页请求参数
export interface ReqPage {
  pageNum: number;
  pageSize: number;
  sortName?: string;
  sortBy?: "asc" | "desc";
}

// 业务实体基础字段
export interface BaseEntity {
  createBy?: string;
  createTime?: string;
  updateBy?: string;
  updateTime?: string;
}

export namespace Upload {
  export interface ResFileUrl {
    fileUrl: string;
  }
}

// 登录模块
export namespace Login {
  export interface ResAuthCode {
    authKey: string;
    authCode: string;
  }
  export interface ReqLogin {
    userName: string;
    password: string;
    authKey: string;
    authCode: string;
  }
  export interface ResLogin {
    accessToken: string;
  }
  export interface ResAuthButtons {
    [key: string]: string[];
  }
}

// 模块
export namespace Mod {
  export interface SysMod extends BaseEntity {
    modId: string;
    machineId?: string;
    modName?: string;
    tableName?: string;
    primaryKey?: string;
    remark?: string;
    isTreeList: string;
    isFlow: string;
    status: string;
    pid?: string;
    formSize: number;
  }
  export interface SysModColumn extends BaseEntity {
    columnId: string;
    modId: string;
    columnName: string;
    columnLabel: string;
    isPrimaryKey: string;
    isSystemColumn: string;
    isAllowNull: string;
    dataType: string;
    dataLength: number;
    dataScale: number;
    defaultValue?: string;
    remark?: string;
    prompt?: string;
    isRequired: string;
    validateRule?: string;
    initValue?: string;
    formula?: string;
    isHide: string;
    isReadonly: string;
    isEditReadonly: string;
    controlType: string;
    controlFormat?: string;
    dataSourceType?: string;
    dataSource?: string;
    isMultiple: string;
    subTableName?: string;
    controlWidth: number;
    controlOrderNum: number;
    isListColumn: string;
    listColumnOrderNum: number;
    listColumnWidth: number;
    isSortColumn: string;
    isDefaultSortColumn: string;
    queryType?: string;
    isQueryMultiple: string;
    isQueryLeft: string;
    queryControlFormat?: string;
    queryOrderNum: number;
    sumType?: string;
    sumColumnName?: string;
    sumFormat?: string;
  }

  export interface SysModInfo extends SysMod {
    columns?: SysModColumn[];
  }

  export interface FireInfo {
    modId: string;
    machineId: string;
    instanceId?: string;
    eventId: string;
    result?: string;
    opinion?: string;
    data?: any;
  }
}
